package ryarithsGame;

import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.scene.Node;

public class Level5 extends Node 
{

	private PuzzleNode[] puzzle;
	private Goal goal;
	private static final long serialVersionUID = 1L;

	public Level5()
	{
		super("Level5");
		loadPuzzle();
	}
	
	private void loadPuzzle()
	{
		goal = new Goal("goal", new Vector3f(20,15,20));
		puzzle = new PuzzleNode[9];
		puzzle[0] = new PuzzleNode("switch0", 1, new Vector3f(30,10,35),new Vector3f(25,10,125));//
		puzzle[1] = new PuzzleNode("switch1", 0, new Vector3f(75,10,75),new Vector3f(125,10,25));
		puzzle[2] = new PuzzleNode("switch2", 0, new Vector3f(125,10,25),new Vector3f(225,10,25));
		
		puzzle[3] = new PuzzleNode("switch3", 1, new Vector3f(25,10,225),new Vector3f(25,10,225));//
		puzzle[4] = new PuzzleNode("switch4", 1, new Vector3f(75,10,175),new Vector3f(75,10,75));//
		puzzle[5] = new PuzzleNode("switch5", 1, new Vector3f(125,10,125),new Vector3f(75,10,175));
		puzzle[6] = new PuzzleNode("switch6", 1, new Vector3f(175,10,75),new Vector3f(125,10,125));
		puzzle[7] = new PuzzleNode("switch7", 0, new Vector3f(225,10,25),new Vector3f(175,10,75));
		
		puzzle[8] = new PuzzleNode("switch8", 0, new Vector3f(400,10,400),new Vector3f(-100,10,-100));//
		
		this.attachChild(goal);
		this.attachChild(puzzle[0]);
		this.attachChild(puzzle[1]);
		this.attachChild(puzzle[2]);
		this.attachChild(puzzle[3]);
		this.attachChild(puzzle[4]);
		this.attachChild(puzzle[5]);
		this.attachChild(puzzle[6]);
		this.attachChild(puzzle[7]);
		this.attachChild(puzzle[8]);
	}
	
	public void updateLevel(float tpf)
	{
		for(int i = 0; i < puzzle.length; i++)
		{
			puzzle[i].updatePuzzleNode(tpf);
		}
		goal.updateGoalNode();	
	}
	
	public void checkSwitchCollisions(Vector2f camPos)
	{
		goal.checkSwitchCollisions(camPos);
	}
	
	public boolean getGoalSwitch()
	{
		return goal.getIsSwitched();
	}
	
	public PuzzleNode getPuzzleNode(int i)
	{
		return puzzle[i];
	}
	
	public int puzzleSize()
	{
		return puzzle.length;
	}
	
	public Goal getGoalNode()
	{
		return goal;
	}
}
